package com.qiaoanju.back.dao.system;

import com.qiaoanju.back.domain.system.UserModel;
import com.qiaoanju.back.dto.system.UserDto;
import com.qiaoanju.dao.SqlMapper;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

/**
 * Created by eversec
 * on 2017/9/21.
 */
public interface IUserDao extends SqlMapper{


    /**
     *
     * @param user
     * @return
     */
    @Insert("insert into t_user(user_name)values(#{user_name})")
    int insert(UserModel user);

    /**
     *
     * @param id
     * @return
     */
    @Select("SELECT * FROM t_user WHERE id = #{id} ")
    UserModel getUserById(Integer id);

    /**
     *
     * @param username
     * @param password
     * @return
     */
    @Select("SELECT * FROM t_user WHERE user_name = #{username}  AND password = #{password}")
    UserModel getUserByNamePwd(@Param("username") String username,@Param("password") String password);

    /**
     *
     * @param username
     * @return
     */
    @Select("SELECT * FROM t_user WHERE user_name = #{username} ")
    UserModel getUserByUsername(String username);


    /**
     *
     * @param username
     * @return
     */
    @Select("SELECT * FROM t_user WHERE user_name = #{username} ")
    UserDto getLoginUserByNamePwd(@Param("username") String username);

}
